﻿<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ReporteVentasClientesVip.aspx.cs"
    Inherits="CrmContacto.WebApp.App.ReporteVentasClientesVip" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<%@ Import Namespace="Web.Framework.Translate" %>
<asp:Content ID="HeaderContent" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="/Styles/App/ReportViewer.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/App/SearchProduct.js" type="text/javascript"></script>
    <script src="/Scripts/App/SearchMini.js" type="text/javascript"></script>
    <style type="text/css">
        #<%= ReportServViewer.ClientID%>_fixedTable
        {
            width:100%;
        }            
    </style>
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="28800">
    </asp:ScriptManager>
    <div class="clear">
    </div>
    <h2>
        <asp:Image Width="15px" Height="15px" ID="imgExpandResults" CssClass="imgExpand"
            ImageUrl="/Images/icon_blockexpanded.png" runat="server" ClientIDMode="Static"
            alt="" onclick="window.AppCommonObj.toggleVisibility(this.id, 'searchBox');" />
        <asp:Label ID="lblSearchResult" runat="server" Text="" CssClass=""></asp:Label>
    </h2>
    <div class="editionContainerFilter" id="searchBox">
        <p>
            <span class="title2">
                <asp:Literal ID="Literal2" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.Reporte.VentasPorCliente.FechaDesde"]%>' />:</span>
            <asp:TextBox ID="txtFechaDesde" runat="server" ClientIDMode="Static" CssClass="inputs"></asp:TextBox>
        </p>
        <p>
            <span class="title2" style="margin-left: 135px">
                <asp:Literal ID="Literal1" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.Reporte.VentasPorCliente.FechaHasta"]%>' />:</span>
            <asp:TextBox ID="txtFechaHasta" runat="server" ClientIDMode="Static" CssClass="inputs"></asp:TextBox>
        </p>
        <div class="clear">
        </div>
        <p class="lstp">
            <span class="title2">
                <asp:Literal ID="Literal16" runat="server" Text='<%$ Code: LocalizationProvider.Instance["PuntoDeVenta"]%>' />:</span>
            <asp:ListBox ID="lstPtoVtas" runat="server" CssClass="lst searchLst" SelectionMode="Multiple"
                ClientIDMode="Static"></asp:ListBox>
        </p>
        <div class="clear">
        </div>
        <div class="commandBarDiv">
            <%--<asp:LinkButton ID="lnkBuscar" runat="server" OnClick="lnkBuscar_Click" OnClientClick="return ValidarBuscar();" ClientIDMode="Static">
                <asp:Literal ID="Literal3" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.Command.ReporteHTML"]%>' />
            </asp:LinkButton>     --%>
            <asp:LinkButton ID="lnkBuscar" runat="server" OnClick="lnkBuscar_Click" ClientIDMode="Static"
                OnClientClick="return ValidarBuscar();">
                <asp:Literal ID="Literal10" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.Command.ReporteHTML"]%>' />
            </asp:LinkButton>
            <%-- <asp:LinkButton ID="lnkDownloadPDF" runat="server" OnClick="lnkDownloadPDF_Click" ClientIDMode="Static" OnClientClick="return ValidarBuscar();">
                <asp:Literal ID="litDownloadPDF" runat="server" Text='<%$ Code: LocalizationProvider.Instance["Bo.Command.ReporteDownloadPDF"]%>' />
            </asp:LinkButton>    --%>
            <div class="clear">
            </div>
        </div>
    </div>
    <asp:HiddenField ID="hidReportViewing" runat="server" ClientIDMode="Static"/>   
    <asp:Panel ID="pnlFramePdf" runat="server" ClientIDMode="Static" Width="100%" Height="100%">
        <iframe id="framePdf" style="width: 100%; height: 600px" runat="server"></iframe>
    </asp:Panel>
    <asp:Panel ID="oReportDiv" runat="server" ClientIDMode="Static">
        <rsweb:ReportViewer ID="ReportServViewer" runat="server" Font-Names="Verdana" Width="100%"
            ClientIDMode="Static" Font-Size="8pt" InteractiveDeviceInfos="(Collection)" ProcessingMode="Remote"
            ShowParameterPrompts="true" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
        </rsweb:ReportViewer>
    </asp:Panel>
    <div class="clear">
    </div>
    <script type='text/javascript'>

        var intervalHandler;
        var maxTries = 10;
        var currentTries = 0;

        function removePDFFromReporting() {
            var clear = false;
            if (intervalHandler != null) {                 
                if ($('#hidReportViewing').val() != '') {                    
                    var anchor = $("#<%= ReportServViewer.ClientID%>_fixedTable  a:contains('PDF')");
                    if (anchor.length == 0) {
                        currentTries = currentTries + 1;
                        clear = currentTries >= maxTries;
                    }
                    else {
                        anchor.remove();
                        clear = true;                       
                    }
                }
            }

            if (clear) {
                $('#hidReportViewing').val('');
                clearInterval(intervalHandler);
                intervalHandler = null;
            }
        }


        $(document).ready(function () {

            if (!window.AppCommonObj) {
                window.AppCommonObj = new AppCommon();
            }

            if (!window.SearchProductJsObj) {
                window.SearchProductJsObj = new SearchProductJs();
            }



            if (!window.SearchMiniJsObj) {
                window.SearchMiniJsObj = new SearchMiniJs();
            }

            $('.footer').remove();

            $('#txtFechaDesde').datepick({ dateFormat: 'dd/mm/yyyy' });
            $('#txtFechaHasta').datepick({ dateFormat: 'dd/mm/yyyy' });

            window.AppCommonObj.initializeEnterKeyEvent($('#resultDiv'), function () {
                __doPostBack($('#lnkBuscar').attr('aspnetid'), '');
            });

            $('.searchLst').dropdownchecklist(
             { icon: {},
                 width: 250,
                 maxDropHeight: 200
             });

            // Pongo un timer para sacar el exportar a excel
            if ($('#hidReportViewing').val() != '')
            {
               intervalHandler = setInterval(removePDFFromReporting, 1500);
            }          
        });

        // Validación
        function ValidarBuscar() {
            var errorPanel = new ErrorPanel();

            var isError = false;
            var strError = '';

            errorPanel.removeErrors();
            var txtDesde = $('#txtFechaDesde');
            var txtHasta = $('#txtFechaHasta');

            var separador = '';
            if (txtDesde.val() == '') {
                isError = true;
                errorPanel.appendAsteriskToJQControl(txtDesde);

                strError += separador;
                strError += JsLocalization_ReporteVentasPorClienteJs_IngresarFechaDesde;
                separador = '<br />';
            }

            if (txtHasta.val() == '') {
                isError = true;
                errorPanel.appendAsteriskToJQControl(txtHasta);

                strError += separador;
                strError += JsLocalization_ReporteVentasPorClienteJs_IngresarFechaHasta;
                separador = '<br />';
            }

            if (isError) {
                errorPanel.showError(JsLocalization_Messages_CompleteElFormulario, strError);
            }

            return !isError;
        }

        //        function showPDFInFrame() {
        //            var frame = $("#framePdf");

        //            var loc = "";
        //            var isign = window.location.href.indexOf("?");
        //            if (isign >= 0) {
        //                loc = window.location.href.substring(0, isign);
        //            }
        //            else {
        //                loc = window.location;
        //            }
        //            alert(loc);
        //            loc = loc + "?embebbed=1";            

        //            $("#oReportDiv").toggle(false);
        //            $("#pnlFramePdf").toggle(true);
        //            $("#pnlFramePdf").css("visibility", "visible");
        //            
        //            frame.attr("src", loc);
        //        }

        function autoResize(id) {
            var newheight;
            var newwidth;

            if (document.getElementById) {
                newheight = document.getElementById(id).contentWindow.document.body.scrollHeight;
                newwidth = document.getElementById(id).contentWindow.document.body.scrollWidth;
            }

            document.getElementById(id).height = (newheight) + "px";
            document.getElementById(id).width = (newwidth) + "px";
        }


    </script>
</asp:Content>
